package com.yzh.demo.controller;

import com.yzh.demo.service.ProductService;
import com.yzh.demo.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author yuzhen
 * @create 2021-12-18 23:02
 */
@Api(tags = "商品管理")
@RestController
@RequestMapping("/api/product")
@CrossOrigin
public class ProductController {

    @Resource
    private ProductService productService;

    @ApiOperation("商品列表")
    @GetMapping("/list")
    public R list(){
        return R.ok().data("productList", productService.list());
    }


    @ApiOperation("测试接口")
    @GetMapping("/test")
    public R test(){
        return R.ok().data("msg", "查询成功").data("now", new Date());
    }
}
